import axios from './index'
const preUrl = ''


// 获取代理列表
const getAgentList = {
  p: [`get,/newproxy/*/list`],
  r: params => {
    axios.defaults.headers.permission = `get,/newproxy/*/list`
    // axios.defaults.headers['Authorization'] = Cookie.get('token');
    return axios.get(`${preUrl}/newproxy/${Cookie.get('areaCode')}/list`, {
      params
    })
  }
}

// 查询代理
const searchAgentList = {
  p: [`get,/newproxy/*/conditions`],
  r: params => {
    axios.defaults.headers.permission = `get,/newproxy/*/conditions`
    return axios.get(`${preUrl}/newproxy/${Cookie.get('areaCode')}/conditions`, {
      params
    })
  }
}

// 修改代理资料
const editAgentDetail = {
  p: [`put,/newproxy/*`],
  r: params => {
    axios.defaults.headers.permission = `put,/newproxy/*`
    return axios.put(`${preUrl}/newproxy/${Cookie.get('areaCode')}`, params)
  }
}

// 输入玩家id得到搜索结果
const searchPlayer = {
  p: [`get,/newproxy/*/*`],
  r: params => {
    axios.defaults.headers.permission = `get,/newproxy/*/*`
    return axios.get(`${preUrl}/newproxy/${Cookie.get('areaCode')}/${params}`)
  }
}

// 授权玩家成为代理
const grantPlayerAccess = {
  p: [`post,/newproxy/*/create`],
  r: params => {
    axios.defaults.headers.permission = `post,/newproxy/*/create`
    return axios.post(`${preUrl}/newproxy/${Cookie.get('areaCode')}/create`, params)
  }
}

// 代理分析详情卡片
const getAgentAnalyzeCard = {
  p: [`get,/newproxy/*/time`],
  r: params => {
    axios.defaults.headers.permission = `get,/newproxy/*/time`
    return axios.get(`${preUrl}/newproxy/${Cookie.get('areaCode')}/time`, {
      params
    })
  }
}

// 代理分析详情表格
const getAgentAnalyzeTable = {
  p: [`get,/newproxy/*/analysislist`],
  r: params => {
    axios.defaults.headers.permission = `get,/newproxy/*/analysislist`
    return axios.get(`${preUrl}/newproxy/${Cookie.get('areaCode')}/analysislist`, {
      params
    })
  }
}

// 搜索代理分析详情
const searchAgentAnalyze = {
  p: [`get,/newproxy/*/condition`],
  r: params => {
    axios.defaults.headers.permission = `get,/newproxy/*/condition`
    return axios.get(`${preUrl}/newproxy/${Cookie.get('areaCode')}/condition`, {
      params
    })
  }
}

// 提交代理追溯
const getAgentDepth = {
  p: [`get,/newproxy/*/ascent`],
  r: params => {
    axios.defaults.headers.permission = `get,/newproxy/*/ascent`
    return axios.get(`${preUrl}/newproxy/${Cookie.get('areaCode')}/ascent`, {
      params
    })
  }
}

// 获取销售排行
const getSaleRank = {
  p: [`get,/performance/*/sales/**`],
  r: params => {
    axios.defaults.headers.permission = `get,/performance/*/sales/**`
    axios.defaults.headers['Authorization'] = Cookie.get('token');
    return axios.get(`${preUrl}/performance/${Cookie.get('areaCode')}/sales`, {
      params
    })
  }
}

// 获取代理工资
const getAgentWage = {
  p: [`get,/proxy/*/salary/**`],
  r: params => {
    axios.defaults.headers.permission = `get,/proxy/*/salary/**`
    axios.defaults.headers['Authorization'] = Cookie.get('token');
    return axios.get(`${preUrl}/proxy/${Cookie.get('areaCode')}/salary`, {
      params
    })
  }
}

export {
  getAgentList,
  searchAgentList,
  getAgentDetails,
  editAgentDetail,
  searchPlayer,
  grantPlayerAccess,
  getAgentAnalyzeCard,
  getAgentAnalyzeTable,
  searchAgentAnalyze,
  getAgentDepth,
  getSaleRank,
  getAgentWage,
}